var a = getApp();

Page({
    data: {
        currentTab: 1
    },
    onLoad: function(t) {
        var e = this;
        a.globalData.phone = wx.getStorageSync("phone"), e.setData({
            nickName: a.globalData.nickName,
            avatarUrl: a.globalData.avatarUrl,
            userId: a.globalData.userId
        }), t.type && e.setData({
            currentTab: t.type
        }), console.log(a.globalData.phone);
        var o = a.globalData.baseUrl + a.globalData.urlRechargrList, r = a.globalData.urlMyRechargr;
        this.getinitData(o, r);
    },
    getinitData: function(t, e) {
        var o = this;
        wx.request({
            url: t,
            data: {
                storeId: a.globalData.storeId,
                lng: a.globalData.lng,
                lat: a.globalData.lat
            },
            method: "POST",
            header: {
                "content-type": "application/x-www-form-urlencoded"
            },
            success: function(t) {
                var r = JSON.parse(t.data);
                0 != r.code ? wx.showToast({
                    title: r.msg,
                    icon: "none",
                    duration: 2e3
                }) : (o.setData({
                    store: r.store,
                    ekId: r.store.ekId
                }), a.globalData.ekStoreId = o.data.ekId, wx.request({
                    url: e,
                    data: {
                        storeId: o.data.ekId,
                        phone: a.globalData.phone
                    },
                    method: "POST",
                    header: {
                        "content-type": "application/x-www-form-urlencoded"
                    },
                    success: function(a) {
                        var t = JSON.parse(a.data);
                        if (0 != t.code) wx.showToast({
                            title: t.msg,
                            icon: "none",
                            duration: 2e3
                        }); else {
                            for (var e = [], r = [], n = 0; n < t.data.length; n++) 1 == t.data[n].type && e.push(t.data[n]), 
                            2 == t.data[n].type && r.push(t.data[n]);
                            o.setData({
                                cards1: e,
                                cards2: r
                            });
                        }
                    }
                }));
            }
        });
    },
    swichNav: function(a) {
        var t = this;
        if (this.data.currentTab === a.target.dataset.current) return !1;
        t.setData({
            currentTab: a.target.dataset.current
        });
    },
    cardLogList: function(a) {
        wx.navigateTo({
            url: "record?carid=" + a.currentTarget.dataset.carid
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onShareAppMessage: function() {}
});